<script setup>
	import {
		onLoad,
		onReady
	} from '@dcloudio/uni-app';
	import {
		ref
	} from "vue";
	import {
		imgUrl
	} from '../../utils/global';
	import {
		getinformationlist,
		memberGetdev
	} from '@/api/index';
	import ShopList from "../../components/shop-list/index";

	const navList = ref([{
			title: "健康百科",
			path: "/pages/wiki/list/index",
		},
		// {
		// 	title: "会员中心",
		// 	path: "",
		// },
		// {
		// 	title: "商城",
		// 	path: "",
		// },
		{
			title: "定制体检",
			path: "/pages/reserve/index/index?quick=1",
		},
	]);
	const health_list = ref([])
	// 健康百科列表
	const getHealthList = () => {
		getinformationlist().then(res => {
			health_list.value = res
		})
	};
	// 健康百科详情
	const healthDetail = (id) => {
		uni.navigateTo({
			url: "/pages/wiki/detail/index?id=" + id
		})
	}
	// 更多健康百科
	const healthMore = () => {
		uni.navigateTo({
			url: "/pages/wiki/list/index"
		})
	}
	onLoad(async (options) => {
		getHealthList()
		getDev()
	})
	const show = ref(false)
	onReady(() => {
		getScreenWidth()

	})
	const togglePath = (url) => {
		if (!url) return;
		uni.navigateTo({
			url,
		});
	};
	// 就医管理
	const medical = () => {
		uni.navigateTo({
			url: "/pages/medical/medical",
		});
	}
	const dev_type = ref(2)
	const getDev = () => {
		memberGetdev().then(res => {
			dev_type.value = res.val
			console.log(res)
		})
	}
	// 出行服务
	const travelServices = (isDev) => {
		uni.navigateTo({
			url: "/pages/travel/index?isDev="+isDev,
		});
	}
	const banner_height = ref(1000)
	const getScreenWidth = () => {
		const systemInfo = uni.getSystemInfoSync(); // 获取系统信息
		banner_height.value = systemInfo.screenWidth / 3 * 4 * 2
	}
</script>

<template>
	<view class="app-index">
		<view class="banner-wrapper" v-if="dev_type==1">
			<!-- <view class="banner-top"></view> -->
			<image :src="imgUrl('/uploads/20250626/316eed18c947a884adc32a8b7f6b93d1.png')" mode="aspectFill"></image>
			<!-- <view class="banner-bottom"></view> -->
		</view>

		<!-- 	<view class="location-wrapper">
			<text>上海</text>
		</view> -->

		<!-- 	<view class="input-wrapper">
			<image :src="imgUrl('/static/img/icons/search.png')"></image>
			<input type="text" placeholder="请输入关键词" />
		</view> -->

		<view class="nav-wrapper" v-if="dev_type==1">
			<view class="nav-item" v-for="(item, index) in navList" :key="`nav-item-${index}`"
				@click="togglePath(item.path)">
				<image :src="imgUrl(`/static/img/icons/nav${index + 1}.png`)" mode="widthFix"></image>
				<text>{{ item.title }}</text>
			</view>
		</view>

		<view class="button-wrapper" style="margin-top:20rpx">
			<view class="button-left" style="flex:1" @click="togglePath('/pages/reserve/index/index?quick=1')">
				<text>体检预约</text>
				<text>预约/取消</text>
				<view class="button-detail" style="position:absolute;bottom:40rpx">
					<text>查看详情</text>
				</view>
				<image class="button-icon" :src="imgUrl('/uploads/20250626/dbf361898958739267316247d3bceb19.png')"
					mode="aspectFill">
				</image>
				<image class="button-bg" style="width:100%;border-radius: 24rpx;"
					:src="imgUrl('/uploads/20250626/f795b041c5a889118350da5dbddc64f6.png')" mode="aspectFill"></image>
			</view>
			<view class="button-right" style="margin-left: 20rpx;" v-if="dev_type==1">
				<view class="button-item" @click="medical()">
					<view class="item-row">
						<text>就医管理</text>
						<image :src="imgUrl('/static/img/icons/button-right-arrow.png')"></image>
					</view>
					<text>提交表单</text>
					<image :src="imgUrl('/static/img/icons/button-icon1.png')" mode="heightFix"></image>
					<image class="button-bg" style="width:100%;border-radius: 24rpx;"
						:src="imgUrl('/static/img/imgs/button-right1.png')" mode="aspectFill">
					</image>
				</view>
				<view class="button-item" @click="travelServices(true)">
					<view class="item-row">
						<text>出行服务</text>
						<image :src="imgUrl('/static/img/icons/button-right-arrow.png')"></image>
					</view>
					<text>方便快捷</text>
					<image :src="imgUrl('/static/img/icons/button-icon2.png')" mode="heightFix"></image>
					<image class="button-bg" :src="imgUrl('/static/img/imgs/button-right2.png')" mode="aspectFill">
					</image>
				</view>
			</view>
		</view>
		<view class="button-wrapper" style="margin-top:20rpx">
			<view class="button-left" style="flex:1;overflow: hidden;" v-if="dev_type==0" @click="medical()">
				<text style=" color:#104D7E">就医管理</text>
				<text  style=" color:#104D7E">提交表单</text>
				<image class="button-icon" :src="imgUrl('/static/img/icons/button-icon1.png')" mode="aspectFill">
				</image>
				<image class="button-bg" style="width:120%;"
					:src="imgUrl('/static/img/imgs/button-right1.png')" mode="aspectFill"></image>
			</view>
		</view>
		<view class="button-wrapper" style="margin-top:20rpx" v-if="dev_type==0" >
			<view class="button-left" style="flex:1;overflow: hidden;" @click="travelServices(true)">
				<text style=" color:#104D7E">出行服务</text>
				<text  style=" color:#104D7E">方便快捷</text>
				<image class="button-icon" :src="imgUrl('/static/img/icons/button-icon2.png')" mode="aspectFill">
				</image>
				<image class="button-bg" style="width:120%;"
					:src="imgUrl('/static/img/imgs/button-right2.png')" mode="aspectFill"></image>
			</view>
		</view>
		<view class="button-wrapper" style="margin-top:20rpx" v-if="dev_type==0">
			<view class="button-left" style="flex:1;overflow: hidden;"  @click="travelServices(false)">
				<text style=" color:#104D7E">出行服务(生产)</text>
				<text  style=" color:#104D7E">方便快捷</text>
				<image class="button-icon" :src="imgUrl('/static/img/icons/button-icon2.png')" mode="aspectFill">
				</image>
				<image class="button-bg" style="width:120%;"
					:src="imgUrl('/static/img/imgs/button-right2.png')" mode="aspectFill"></image>
			</view>
		</view>
		<view class="shop-wrapper" v-if="dev_type==1">
			<view class="shop-header">
				<view class="header-left">
					<image :src="imgUrl('/static/img/icons/hot.png')" mode="aspectFill"></image>
					<text>热门商品</text>
				</view>
				<view class="header-right">
					<text>更多</text>
					<image :src="imgUrl('/static/img/icons/right-arrow.png')"></image>
				</view>
			</view>
			<ShopList :data="[1, 1]" />
		</view>
		<view class="app-split" v-if="dev_type==1"></view>
		<view class="news-wrapper" v-if="dev_type==1">
			<view class="news-header">
				<view class="header-left">
					<text>健康百科</text>
					<view></view>
				</view>
				<view class="header-right" @click="healthMore()">
					<text>更多</text>
					<image :src="imgUrl('/static/img/icons/right-arrow.png')"></image>
				</view>
			</view>
			<!-- <view class="news-sort">
				<view class="sort-item">
					<text>全部</text>
				</view>
				<view class="sort-item">
					<text>医疗</text>
				</view>
				<view class="sort-item">
					<text>疫苗</text>
				</view>
			</view> -->
			<view class="news-list">
				<view class="list-item" v-for="(item,index) in health_list" :key="item.id"
					@click="healthDetail(item.id)">
					<view class="item-info">
						<text>{{item.title}}</text>
						<text>{{item.release_time}}</text>
					</view>
					<image :src="imgUrl(item.img)" mode="aspectFill"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<style src="./style.scss" scoped />